#include <vector> 
#include <stdio.h> 
#include <string> 
#include <iostream> 

int test_move1()  
{  
    std::string str = "Hello";  
    std::vector<std::string> v;  
  
    // uses the push_back(const T&) overload, which means we'll incur the cost of copying str  
    v.push_back(str);  
    std::cout << "After copy, str is \"" << str << "\"\n";  
  
    // uses the rvalue reference push_back(T&&) overload, which means no strings will be copied;  
    // instead, the contents of str will be moved into the vector.  
    // This is less expensive, but also means str might now be empty.  
    v.push_back(std::move(str));  
    std::cout << "After move, str is \"" << str << "\"\n";  
  
    std::cout << "The contents of the vector are \"" << v[0] << "\", \"" << v[1] << "\"\n";  
  
    return 0;  
}


class test {
public:
    test() { printf("constructor!\n"); }
    ~test() {printf("deconstructor!\n"); }

    test(const test& rt) { printf("copy constructor!\n"); }
    test(const test&& ) { printf("move constructor!\n"); }
    test& operator=(const test& rt) { printf("operator!\n"); }

private:

};


int main(int argc, char **argv) {
    std::vector<test> vt;
    vt.reserve(2);
    test t1;
    test t2;

    printf("-------------t1 start----------\n");
    vt.push_back(t1);
    printf("-------------t1 end----------\n");
    printf("-------------t2 start----------\n");
    vt.push_back(std::move(t2));
    printf("-------------t2 end----------\n");

    printf("-------------t3 start----------\n");
    test t3 = std::move(t1);
    printf("-------------t3 end----------\n");
    return 0;
}
